package com.summer.dao;

import java.util.Map;

public class User {
	private long id;
	private String name;
	private String password;
	private String sex;
	private int age;
	
	public User() {
		
	}
	
	public User(String name, String password, String sex, int age) {
		this(0, name, password, sex, age);
	}
	
	public User(long id, String name, String password, String sex, int age) {
		this.id = id;
		this.name = name;
		this.password = password;
		this.sex = sex;
		this.age = age;
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("id:").append(id).append(" ")
		.append("姓名：").append(name).append(" ")
		.append("密码：").append(password).append(" ")
		.append("性别：").append(sex).append(" ")
		.append("年龄：").append(age);
		return builder.toString();
	}

	public static User from(Map<String, Object> data) {
		return new User((long) data.get("id"), 
				String.valueOf(data.get("name")), 
				String.valueOf(data.get("password")), 
				String.valueOf(data.get("sex")), 
				(int) data.get("age"));
	}
}
